{$CLEO .cs}
{$USE CLEO+}
{$USE ini}

0000: NOP

script_name "WD Shotgun"

// By ArtemQa146

if
    0AA2: 31@ = load_dynamic_library "CLEO+.cleo"
then
    if
        0AA4: 30@ = get_dynamic_library_procedure "GetCleoPlusVersion" library 31@
    then
        0AA7: call_function_return 30@ num_params 0 pop 0 29@
        if
            not 29@ >= 0x1020000
        then
            0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
            0AA3: free_dynamic_library 31@
            0A93: terminate_this_custom_script
        end
        0AA3: free_dynamic_library 31@
    end
else
    0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
    0AA3: free_dynamic_library 31@
    0A93: terminate_this_custom_script
end

if
    0E2D: is_game_first_start
then
    0F00: load_special_model_dff "Shotgspa\Shotgspa_S" txd "Shotgspa\Shotgspa" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "Shotgspa_S"
    0F00: load_special_model_dff "Shotgspa\Shotgspa_R" txd "Shotgspa\Shotgspa" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "Shotgspa_R"
    0F00: load_special_model_dff "Shotgspa\Shotgspa_O" txd "Shotgspa\Shotgspa" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "Shotgspa_O"
    0F00: load_special_model_dff "chromegun\chromegun_S" txd "chromegun\chromegun" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "chromegun_S"
    0F00: load_special_model_dff "chromegun\chromegun_O" txd "chromegun\chromegun" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "chromegun_O"
    0F00: load_special_model_dff "sawnoff\sawnoff_S" txd "sawnoff\sawnoff" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "sawnoff_S"
    0F00: load_special_model_dff "sawnoff\sawnoff_R" txd "sawnoff\sawnoff" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "sawnoff_R"
end

const
    SHotGSPA_s = 31@
    SHotGSPA_r = 30@
    SHotGSPA_o = 29@
    SHotGSPA_Clip_X = 28@
    SHotGSPA_Clip_Y = 27@
    SHotGSPA_Clip_Z = 26@
    chromegun_S = 25@
    chromegun_0 = 24@
    chromegun_Clip_X = 23@
    chromegun_Clip_Y = 22@
    chromegun_Clip_Z = 21@
    Sawnoff_s = 20@
    Sawnoff_r = 19@
    Sawnoff_s2 = 18@
    Sawnoff_r2 = 17@
    
end

repeat
wait 0
until player.Defined(0)

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "Shotgspa_S"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale SHotGSPA_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF2: SHotGSPA_Clip_X = get_float_from_ini_file "cleo\Shotgspa.ini" section "settings" key "Clip X"
0AF2: SHotGSPA_Clip_Y = get_float_from_ini_file "cleo\Shotgspa.ini" section "settings" key "Clip Y"
0AF2: SHotGSPA_Clip_Z = get_float_from_ini_file "cleo\Shotgspa.ini" section "settings" key "Clip Z"
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "Shotgspa_R"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset SHotGSPA_Clip_X SHotGSPA_Clip_Y SHotGSPA_Clip_Z rotation 0 0 0 scale SHotGSPA_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "Shotgspa_O"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale SHotGSPA_o // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "chromegun_S"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale chromegun_S // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "chromegun_O"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale chromegun_0 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tor

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "sawnoff_S"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale Sawnoff_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF2: 1@ = get_float_from_ini_file "cleo\sawnoff.ini" section "settings" key "Clip X"
0AF2: 2@ = get_float_from_ini_file "cleo\sawnoff.ini" section "settings" key "Clip Y"
0AF2: 3@ = get_float_from_ini_file "cleo\sawnoff.ini" section "settings" key "Clip Z"
0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "sawnoff_R"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 1@ 2@ 3@ rotation 0 0 0 scale Sawnoff_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "sawnoff_S"
0F02:  $PLAYER_ACTOR special_model 0@ bone 34 offset 0.03 0.03 0 rotation 0 180.0 180.0 scale Sawnoff_s2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF2: 1@ = get_float_from_ini_file "cleo\sawnoff.ini" section "settings" key "Clip X2"
0AF2: 2@ = get_float_from_ini_file "cleo\sawnoff.ini" section "settings" key "Clip Y2"
0AF2: 3@ = get_float_from_ini_file "cleo\sawnoff.ini" section "settings" key "Clip Z2"

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "sawnoff_R"
0F02:  $PLAYER_ACTOR special_model 0@ bone 34 offset 1@ 2@ 3@ rotation 0 180.0 180.0 scale Sawnoff_r2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0E31: set_render_object_visible SHotGSPA_s 0
0E31: set_render_object_visible SHotGSPA_r 0
0E31: set_render_object_visible SHotGSPA_o 0

0E31: set_render_object_visible chromegun_s 0
0E31: set_render_object_visible chromegun_0 0

0E31: set_render_object_visible Sawnoff_s 0
0E31: set_render_object_visible Sawnoff_s2 0
0E31: set_render_object_visible Sawnoff_r 0
0E31: set_render_object_visible Sawnoff_r2 0


while true
wait 0
    if
        player.Defined(0)
    then
        if
            actor.Driving($PLAYER_ACTOR)
        then
            continue
        end

        0AAA: 1@ = get_script_struct_named 'Shtgsp'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 27
            1@ == 0
        then
            0A92: stream_custom_script "Shotgspa.qa" SHotGSPA_s SHotGSPA_r SHotGSPA_o SHotGSPA_Clip_X SHotGSPA_Clip_Y SHotGSPA_Clip_Z
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Shtgsp'
            until 1@ > 0
            continue
        end

        0AAA: 1@ = get_script_struct_named 'Chrmgun'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 25
            1@ == 0
        then
            0A92: stream_custom_script "Chromegun.qa" chromegun_s chromegun_0
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Chrmgun'
            until 1@ > 0
            continue
        end

        0AAA: 1@ = get_script_struct_named 'Sawnqa'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 26
            1@ == 0
        then
            0A92: stream_custom_script "Sawnoff.qa" Sawnoff_s Sawnoff_r Sawnoff_s2 Sawnoff_r2
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Sawnqa'
            until 1@ > 0
            continue
        end

    end
end